<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    * {
        margin: 0;
        padding: 0;
        list-style: none;
    }

    img {
        width: 100px;
        height: 100px;
        position: absolute;
        /* 这里是不能少的,不然怎么跟着移动呢*/
    }
</style>

<body>
    <img src="../img//bird.png" alt="">
</body>
<script>
    window.onload = function () {
        var img = document.getElementsByTagName('img')[0];
        console.log(img);

        document.onmousemove = function (e) {
            img.style.left = e.clientX + 'px';
            img.style.top = e.clientY + 'px';
        }
    }
</script>

</html>